<template>
  <div class="photoinfo-container">
    <h3 class="title">{{photoInfo.title}}</h3>
    <p class="subtitle">
      <span>发表时间：{{photoInfo.add_time | dateFormat}}</span>
      <span>点击：{{photoInfo.click}}次</span>
    </p>
    <hr>
    <!-- 缩略图区域 -->
    <div class="thumbs">
      <vue-preview :slides="list"></vue-preview>
    </div>
    <!-- 评论区 -->
    <div class="container" v-html="photoInfo.content"></div>
    <comment :id="this.id"></comment>
  </div>
</template>

<script>
import {Toast} from 'mint-ui'
import comment from '@/components/subcomponents/comment'
export default {
  data () {
    return {
      id: this.$route.params.id,
      photoInfo: {},
      list: []
    }
  },
  created () {
    this.getPhotoInfo()
    this.getThumbs()
  },
  methods: {
    getPhotoInfo () {
      this.$http.get('http://www.liulongbin.top:3005/api/getimageInfo/' + this.id).then(result => {
        if (result.body.status === 0) {
          this.photoInfo = result.body.message[0]
        } else {
          Toast('加载详情失败...')
        }
      })
    },
    getThumbs () {
      this.$http.get('http://www.liulongbin.top:3005/api/getthumimages/' + this.id).then(result => {
        if (result.body.status === 0) {
          result.body.message.forEach(item => {
            item.w = 600
            item.h = 400
            item.msrc = item.src
          })
          this.list = result.body.message
        } else {
          Toast('加载图片失败...')
        }
      })
    }
  },
  components: {
    comment
  }
}
</script>

<style lang="scss" scoped>
.photoinfo-container{
  padding: 0 4px;
  .title{
    font-size: 15px;
    text-align: center;
    margin: 15px 0;
    color: #26A2FF;
  }
  .subtitle{
    font-size: 13px;
    display: flex;
    justify-content: space-between;
  }
  .container{
    font-size: 13px;
    line-height: 30px;
  }
  .thumbs {
  /deep/ .my-gallery {
    display: flex;
    flex-wrap: wrap;
    figure {
      width: 30%;
      margin: 5px;
      img {
        width: 100%;
      }
    }
  }
  }
}
</style>
